package com.bw.a2207a.view.fragment

import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bw.a2207a.R
import com.bw.a2207a.base.BaseFragment
import com.bw.a2207a.bean.CommentBean
import com.bw.a2207a.bean.TypeBean
import com.bw.a2207a.bean.TypeItemBean
import com.bw.a2207a.databinding.FragmentCommentBinding
import com.bw.a2207a.databinding.FragmentHomeBinding
import com.bw.a2207a.databinding.FragmentTypeBinding
import com.bw.a2207a.view.adapter.CommentAdapter
import com.bw.a2207a.view.adapter.TypeLeftAdapter
import com.bw.a2207a.view.adapter.TypeRightAdapter
import com.bw.a2207a.viewmodel.GoodsDetailViewModel
import com.bw.a2207a.viewmodel.LoginViewModel
import com.bw.a2207a.viewmodel.TypeViewModel
import com.zhy.adapter.recyclerview.MultiItemTypeAdapter.OnItemClickListener

/**
 * create an instance of this fragment.
 */
class CommentFragment :
    BaseFragment<FragmentCommentBinding, GoodsDetailViewModel>(R.layout.fragment_comment) {
    lateinit var adapter: CommentAdapter
    val datas = mutableListOf<CommentBean>()
    override fun initData() {
        viewModel.commentBeanLiveData.observe(this) {
            if (it.code == 200) {
                datas.clear()
                datas.addAll(it.data)
                adapter.notifyDataSetChanged()

            }
        }
    }

    override fun initView() {

        //获取评论列表
        viewModel.getComment(1)

        //左侧分类列表
        binding.rvComment.layoutManager = LinearLayoutManager(activity)
        adapter = CommentAdapter(activity, R.layout.item_comment_layout, datas)
        binding.rvComment.adapter = adapter


    }


}